package com.zj.sy.controller;

import com.zj.sy.api.ApiResult;
import com.zj.sy.service.CommService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @description:
 * @author: Carver Zhang
 * @create: 2021-08-11 21:48
 **/
@RestController
@RequestMapping("/comm")
public class CommController {

    @Autowired
    private CommService commService;


    @GetMapping("/getYBSS")
    public ApiResult getYBSS(@RequestParam(required = false) String pos) {
        return ApiResult.data(this.commService.getYBSS(pos));
    }

    @GetMapping("/getCityArea")
    public ApiResult getCityArea(@RequestParam(required = false) String pos) {
        return ApiResult.data(this.commService.getCityArea(pos));
    }

    @GetMapping("/getGridTeam")
    public ApiResult getGridTeam(@RequestParam(required = false) String pos) {
        return ApiResult.data(this.commService.getGridTeam(pos));
    }

    @GetMapping("/getGridNum")
    public ApiResult getGridNum(@RequestParam(required = false) String pos) {
        return ApiResult.data(this.commService.getGridNum(pos));
    }

    @GetMapping("/getGriderRank")
    public ApiResult getGriderRank(@RequestParam(required = false) String pos, @RequestParam String year,
                                   @RequestParam String month, @RequestParam int sort) {
        return ApiResult.data(this.commService.getGriderRank(pos, year, month, sort));
    }

    @GetMapping("/getDealNums")
    public ApiResult getDealNums(@RequestParam(required = false) String pos) {
        return ApiResult.data(this.commService.getDealEventNums(pos));
    }

    @GetMapping("/getRecentEvent")
    public ApiResult getRecentEvent(@RequestParam(required = false) String pos) {
        return ApiResult.data(this.commService.getRecentEvent(pos));
    }

    @GetMapping("/getThisMonthCounts")
    public ApiResult getThisMonthCounts(@RequestParam(required = false) String pos) {
        return ApiResult.data(this.commService.getThisMonthEventCounts(pos));
    }

    @GetMapping("/getRecYearCounts")
    public ApiResult getRecYearCounts(@RequestParam(required = false) String pos) {
        return ApiResult.data(this.commService.getThisYearEventCounts(pos));
    }

    //  网格全要素展开

    /**
     * 1.	常住人口/流动人口/境外人口
     *
     * @param pos
     * @return
     */
    @GetMapping("getAllPopulation")
    public ApiResult getAllPopulation(@RequestParam(required = false) String pos) {
        return ApiResult.data(this.commService.getAllPopulation(pos));
    }

    /**
     * 2.	网格队伍
     * 321112	丹徒区
     * 321102	京口区
     * 321193	高新区
     * 321192	新区
     * 321182	扬中市
     * 321111	润州区
     * 321183	句容市
     * 321181	丹阳市
     *
     * @param pos
     * @return
     */
    @GetMapping("getGridTeam2")
    public ApiResult getGridTeam2(@RequestParam(required = false) String pos) {
        return ApiResult.data(this.commService.getGridTeam2(pos));
    }

    /**
     * 3.	网格数量
     *
     * @param pos
     * @return
     */
    @GetMapping("/getGridCounts")
    public ApiResult getGridCounts(@RequestParam(required = false) String pos) {
        return ApiResult.data(this.commService.getGridCounts(pos));
    }

    /**
     * 4.	常住人口
     *
     * @param pos
     * @return
     */
    @GetMapping("getPermanentPopulation")
    public ApiResult getPermanentPopulation(@RequestParam(required = false) String pos) {
        return ApiResult.data(this.commService.getPermanentPopulation(pos));
    }

    /**
     * 5.	流动人口
     *
     * @param pos
     * @return
     */
    @GetMapping("getFloatingPopulation")
    public ApiResult getFloatingPopulation(@RequestParam(required = false) String pos) {
        return ApiResult.data(this.commService.getFloatingPopulation(pos));
    }

    /**
     * 6.	矛盾纠纷
     *
     * @param pos
     * @return
     */
    @GetMapping("getDisputeNums")
    public ApiResult getDisputeNums(@RequestParam(required = false) String pos) {
        return ApiResult.data(this.commService.getDisputeNums(pos));
    }

    /**
     * 7.命案信息
     *
     * @param pos
     * @return
     */
    @GetMapping("getHomicideCase")
    public ApiResult getHomicideCase(@RequestParam(required = false) String pos, @RequestParam(required = false) Integer year) {
        return ApiResult.data(this.commService.getHomicideCase(pos, year));
    }

    //	乡镇排名展开

    /**
     * 1.考核排名
     *
     * @param pos
     * @return
     */
    @GetMapping("getAssessmentRankings")
    public ApiResult getAssessmentRankings(@RequestParam(required = false) String pos) {
        return ApiResult.data(this.commService.getAssessmentRankings(pos));
    }

    //	网格员展开

    /**
     * 1.最美网格员
     *
     * @param pos
     * @return
     */
    @GetMapping("getMostBeautifulGridWorker")
    public ApiResult getMostBeautifulGridWorker(@RequestParam(required = false) String pos) {
        return ApiResult.data(this.commService.getZMWGY(pos));
    }

    /**
     * 2.积分排名
     *
     * @param pos
     * @return
     */
    @GetMapping("getPointsRanking")
    public ApiResult getPointsRanking(@RequestParam(required = false) String pos) {
        return ApiResult.data(this.commService.getPointsRanking(pos));
    }

    //	实时案件展开

    /**
     * 1.实时案件
     *
     * @param pos
     * @param type  类型  1:Csgl;
     *              2:Shwd;
     *              3:Ggaq
     * @param wgbm  网格编码
     * @param state 案件状态
     * @return
     */
    @GetMapping("/getRecentEvent2")
    public ApiResult getRecentEvent2(@RequestParam(required = false) String pos, String type,
                                     String wgbm, String state) {
        return ApiResult.data(this.commService.getRecentEvent3(pos, type, wgbm, state));
    }
    
    @GetMapping("/getOneToFiveEvent")
    public ApiResult getOneToFiveEvent(@RequestParam(required = false) String pos,String wgbm) {
    	return ApiResult.data(this.commService.getOneToFiveEvent(pos, wgbm));
    }
    
    @GetMapping("/getOneToFiveEventDo")
    public ApiResult getOneToFiveEventDo(@RequestParam(required = true) String busiNumber) {
    	return ApiResult.data(this.commService.getOneToFiveEventDo(busiNumber));
    }

    /**
     * 2.重点人员、特殊人员、关怀对象
     *
     * @param pos
     * @return
     */
    @GetMapping("getFocus")
    public ApiResult getFocus(@RequestParam(required = false) String pos) {
        return ApiResult.data(this.commService.getFocus(pos));
    }

    /**
     * 1.建筑物
     *
     * @param pos
     * @return
     */
    @GetMapping("getBuilding")
    public ApiResult getBuilding(@RequestParam(required = false) String pos) {
        return ApiResult.data(this.commService.getBuilding(pos));
    }

    /**
     * 2.实有单位
     *
     * @param pos
     * @return
     */
    @GetMapping("getUnit")
    public ApiResult getUnit(@RequestParam(required = false) String pos) {
        return ApiResult.data(this.commService.getUnit(pos));
    }

    /**
     * @param pos
     * @param desc  F:ASC  T:DESC
     * @param year  年份
     * @param month 月份
     * @return
     */
    @GetMapping("getTownsRank")
    public ApiResult getTownsRank(@RequestParam(required = false) String pos, Boolean desc, Integer year, Integer month, @RequestParam(defaultValue = "10") Integer limit) {
        return ApiResult.data(this.commService.getTownsRank(pos, desc, year, month, limit));
    }

}
